Rem
File:	TEventSystem.bmx
History:
	-4.09.10 Created By Maximilian Micko

(c)Rainbow Productions
Part of the Rainbow-Enging(R)
End Rem

Type tEventSystem
	Method RegisterEventListener(entity:TEntity Var, listener:Object)
		entity.Listeners.Add(listener)
	End Method
End Type

Type tEventListeners
	Field Listeners:TList

	Method New()
		Listeners = New TList
	End Method
	
	Method Add(listener:Object)
		Listeners.AddLast(listener)
	End Method
	
	Method OnEvent(event:String, data:Object = Null)
		Local eData:tEventData = tEventData.Create(event, data)
		Local obj:tEventListener
		For obj = EachIn Listeners
			obj.OnListenerCalled(eData)
		Next
	End Method
	
End Type

Type tEventListener
	Method OnListenerCalled(eData:tEventData Var) Abstract
End Type

Type tEventData
	Field Name:String
	Field Data:Object
	
	Function Create:tEventData(name:String, data:Object)
		Local _self:tEventData = New tEventData
		_self.Name = name
		_self.Data = data
		Return _self
	End Function
End Type